/**
 * Created by Marcello on 2017/3/17.
 */
// 设置右边内容显示
function conShow() {
  $('.link-hoop').click(function () {
    var _href = $(this).attr('href');
    $('#mainShow').attr('src',_href);
  });
}

$(function () {


// 左侧目录栏拉伸
var bar = document.getElementsByClassName("bar")[0];
var catalog = document.getElementsByClassName("catalog")[0];
var widthBar = bar.offsetWidth;
var mouseLeft;
var SIGN = 0;
bar.addEventListener("mousedown",function () {
  SIGN = 1;
},false);
window.addEventListener("mousemove",function (e) {
  e = e || window.event;
  if (SIGN == 1) {
    mouseLeft = e.pageX;
    // 易用性
    if (mouseLeft < 195 ) {mouseLeft = 180}
    if (mouseLeft < 255 && mouseLeft > 220) {mouseLeft = 230}
    if (mouseLeft > 270 ) {mouseLeft = 290}
    catalog.style.flex="0 0 "+ (mouseLeft + widthBar/2)+'px';
  }
},false);
window.addEventListener("mouseup",function (e) {
  e = e || window.event;
  SIGN = 0;
},false);

// 初始化左侧目录栏下拉状态
function initCollapse() {
  $('.collapse').parent('.card:nth-child(n+2)').children('.card-header').addClass('_close')
}
initCollapse();
// 左侧目录栏下拉样式状态设置
$('.card').on('hide.bs.collapse', function () {
  $(this).children('.card-header').addClass('_close');
  $(this).children('.blog-title-hook').removeClass('text-hide').removeClass('mb-0');
});
$('.card').on('hidden.bs.collapse', function () {
  $(this).children('.blog-title-hook').addClass('visible_');
});

$('.card').on('show.bs.collapse', function () {
  $(this).children('.blog-title-hook').addClass('text-hide').addClass('mb-0').removeClass('visible_');
});
$('.card').on('shown.bs.collapse', function () {
  $(this).children('.card-header').removeClass('_close');
  $(this).children('.blog-title-hook').addClass('text-hide');
});


// 鼠标悬停显示完整内容
function setTitle() {
  // 设置文章标题的 title属性值
  $('.atc-name').each(function () {
    var atcName = $(this).text();
    $(this).attr('title',atcName);
  })
  // 设置时间的 title属性值
   $('.time17').each(function () {
     var time17 = $(this).text();
     $(this).attr('title','2017年'+time17);
  })
}
setTitle();



// 返回旧版入口动画
  var _expanding = false;
  $('.old-entra-hook').hover(function () {
    _expanding=true;
    $(this).stop().animate({
      width: '80px',
      padding:'3px 5px 3px 5px'
    },200).css({'background':'#DEB887'})
  },function () {
    $(this).stop().animate({
      width: '10px',
      padding:'3px 0px 3px 10px'
    },200,function () {
      $(this).css({'background':'#C0C0C0'})
    })
  });

})